<%@ Control Language="C#" AutoEventWireup="true" CodeFile="searchresults.ascx.cs" Inherits="forums_controls_search_searchresults" %>
<%@ Register Src="../misc/Pager.ascx" TagName="Pager" TagPrefix="uc1" %>
<div style="background : #EEEEEE; border : #AAAAAA 2px solid;">
<asp:Label runat="server" ID="lblResults" />
<uc1:Pager ID="Pager1" runat="server"
    HeaderText=" | Page ("
    FooterText=")"
    MaximumPages="20"/>
<asp:MultiView runat="server" ID="mviewResults">
    <asp:View runat="server" ID="viewThreadMode">
        <asp:GridView runat="server" ID="gridThreads" AutoGenerateColumns="false" Width="100%" GridLines="None">
            <Columns>
                <asp:TemplateField>
                    <HeaderTemplate>Thread</HeaderTemplate>
                    <ItemTemplate>
                        (<asp:HyperLink runat="server" ID="lnkThreadForum"
                            Text='<%# Helpers.StringHelper.SafeFormat(Eval("Forum.Name")) %>'
                            NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/forum.aspx?f={0}", Eval("Forum.ID")) %>'/>)
                            
                        <asp:HyperLink runat="server" ID="lnkFirstPost"
                            NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/thread.aspx?t={0}", Eval("ID")) %>'
                            Text='<%# Helpers.StringHelper.SafeFormat(Eval("FirstPost.Subject")) %>'
                        />
                        <uc1:Pager ID="Pager1" runat="server"
                            TotalPages='<%# Eval("TotalPages") %>'
                            HeaderText="(Page "
                            FooterText=")"
                            MaximumPages="10"
                            CurrentPage="0"
                            UrlFormat='<%# Helpers.StringHelper.SafeFormat("~/forums/thread.aspx?t={0}&page={{0}}", Eval("ID")) %>' />
                        <br />
                        <asp:HyperLink runat="server" ID="lnkThreadStarter"
                            Text='<%# Helpers.StringHelper.SafeFormat(Eval("FirstPost.User.Username")) %>'
                            NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/profile.aspx?u={0}", Eval("FirstPost.User.ID")) %>' />
                    </ItemTemplate>
                    <HeaderStyle CssClass="forum_primary_header" />
                </asp:TemplateField>
                <asp:BoundField DataField="TotalReplies" HeaderText="Posts" >
                    <HeaderStyle CssClass="forum_secondary_header" />
                    <ItemStyle CssClass="forum_secondary_item" />
                </asp:BoundField>
                <asp:BoundField DataField="TotalViews" HeaderText="Views" >
                    <HeaderStyle CssClass="forum_secondary_header" />
                    <ItemStyle CssClass="forum_secondary_item" />
                </asp:BoundField>
                <asp:TemplateField>
                    <HeaderTemplate>Last Post</HeaderTemplate>
                    <ItemTemplate>
                        <asp:HyperLink runat="server" ID="lnkUser"
                            Text='<%# Helpers.StringHelper.SafeFormat(Eval("LastPost.User.Username")) %>'
                            NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/profile.aspx?u={0}", Eval("LastPost.User.ID")) %>'/>
                        <sup>
                        <asp:HyperLink runat="server" ID="lnkLastPost"
                            Text="-&gt;"
                            NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/thread.aspx?p={0}#{0}", Eval("LastPost.ID")) %>'
                        />
                        </sup>
                        <%# (Eval("LastPost") as DAL.Post).DatePosted.ToString("yyyy-MMM-dd hh:mm tt") %>
                    </ItemTemplate>
                    <HeaderStyle CssClass="forum_secondary_header" />
                </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                Be the first person to create start a new thread in this forum, you dirty troglodyte, you.
            </EmptyDataTemplate>
            <AlternatingRowStyle CssClass="forum_altgridrow" />
        </asp:GridView>
    </asp:View>
    <asp:View runat="server" ID="viewPostMode">
        <asp:Repeater runat="server" ID="rptPosts" EnableViewState="false">
            <ItemTemplate>
                <div>&nbsp;</div>
                <table width="95%" align="center" cellspacing="5">
                    <tr>
                        <td>
                            <asp:HyperLink runat="server" ID="lnkForum"
                                Text='<%# Helpers.StringHelper.SafeFormat(Eval("Thread.Forum.Name")) %>'
                                NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/forum.aspx?f={0}", Eval("ID")) %>'
                                /> - 
                            <asp:HyperLink runat="server" ID="lnkThread"
                                Text='<%# Helpers.StringHelper.SafeFormat(Eval("Thread.FirstPost.Subject")) %>'
                                NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/thread.aspx?t={0}", Eval("Thread.ID")) %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="background-color : #FFEEEE; border : #AA0000 2px solid;">
                            <p>
                                <asp:HyperLink runat="server" ID="lnkProfile"
                                    Text='<%# Helpers.StringHelper.SafeFormat(Eval("User.Username")) %>'
                                    NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/profile.aspx?u={0}", Eval("ID")) %>' />
                            </p>
                            <p>
                                <i>
                                <asp:HyperLink runat="server" ID="lnkPost"
                                    NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/thread.aspx?p={0}#{0}", Eval("ID")) %>'>
                                    <%# Helpers.StringHelper.FormatIfExists("<b>{0}</b><br />", Eval("Subject")) %>
                                    <%# GetPostText(Eval("Content") as string) %>
                                    </asp:HyperLink>
                                </i>
                            </p>
                            <p>
                                <%# Convert.ToDateTime(Eval("DatePosted")).ToString("yyyy-MMM-dd hh:mm tt") %>
                            </p>
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:Repeater>
    </asp:View>
    <asp:View runat="server" ID="viewOhNoes">
        <p>
            No results found matching criteria.
        </p>
    </asp:View>
</asp:MultiView>
</div>
